<?php

namespace plugin\ycMassage\app\model;


class MassageUserTechnicianService extends Model
{
	public static function onAfterRead($model)
	{
		if ($model->price) {
			$model->price = (float)$model->price;
		}
		if ($model->overtime_price) {
			$model->overtime_price = (float)$model->overtime_price;
		}
	}
	public static function cancelMch($uid, $mch_id)
	{
		$models = self::alias('uts')->where(['uts.uid' => $uid, 's.mch_id' => $mch_id])
			->join('massage_service s', 's.id=uts.service_id')->field('uts.*')->select();
		foreach ($models as $model) {
			$model->delete();
		}
	}
	public static function cancelShop($uid, $shop_id)
	{
		$models = self::alias('uts')->where(['uts.uid' => $uid, 's.shop_id' => $shop_id])
			->join('massage_service s', 's.id=uts.service_id')->field('uts.*')->select();
		foreach ($models as $model) {
			$model->delete();
		}
	}
}
